package com.directthought.simpletapestry;

import org.apache.tools.ant.Project;
import org.apache.tools.ant.ProjectHelper;

import java.io.File;
import java.io.IOException;

public class ShellCreator {

	public static void main(String[] args){
		if (args.length != 1){
     	System.err.println("You must supply the project name as the");
			System.err.println("only command line argument.");
			System.err.println("usage: simpletapestry [project_name]");
			System.exit(1);
		}

    String st_home = System.getProperty("st.home");
		String baseDir = st_home + File.separator + "tasks";

		Project project = new Project();
		project.init();

		String current_directory = (new File(".")).getAbsolutePath();
		String to_dir = current_directory + File.separator + args[0];

		File buildFile = new File( baseDir , "create.xml" );
		ProjectHelper.configureProject( project, buildFile );
		project.setProperty( "st.home",        st_home );
		project.setProperty( "project.name" ,  args[0]);
		project.setProperty( "project.toDir" , to_dir);
		project.executeTarget( "build" );
	}
  
}
